package com.lb.util;

import java.util.PriorityQueue;

public class Trie {
	
	public static void main(String[] args) {
		PriorityQueue<Integer> heap=new PriorityQueue<Integer>();
		int[] fenshu= {10,20,30,40,32};
		int sum=0;
		for(int i:fenshu) {
			heap.add(i);
		}
		while(heap.size()>1) {
			int temp=heap.poll()+heap.poll();
			sum=sum+temp;
			heap.add(temp);
		}
		System.out.println(sum);
	}
}

